//
//  UIWindow+AMchangeRootVcTool.m
//  AMwb
//
//  Created by zhc on 15/12/3.
//  Copyright © 2015年 zhc. All rights reserved.
//

#import "UIWindow+AMchangeRootVcTool.h"
#import "AMNewFeatureController.h"
#import "AMTabBarViewController.h"

@implementation UIWindow (AMchangeRootVcTool)


- (void)switchrootVc{

        //从info中获得 版本号
    
        NSString *key=@"CFBundleVersion";
        NSString *currentVerson =[NSBundle mainBundle].infoDictionary[key];
        // NSLog(@"%@",[NSUserDefaults standardUserDefaults]);
        //上一次的版本
        NSString *lastKey=[[NSUserDefaults standardUserDefaults] objectForKey:key];
    
    
        //获得window
    
          //UIWindow *window=[UIApplication sharedApplication].keyWindow;
    
    
    
        if ([lastKey isEqualToString: currentVerson]) {//一样的版本号，直接进入主页
            
            
            //window.rootViewController = [[AMTabBarViewController alloc]init];
            
            self.rootViewController=[[AMTabBarViewController alloc]init];
        }else{ //不一样的版本号，新特性
    
            self.rootViewController = [[AMNewFeatureController alloc]init];
    
            //将新的版本号放进沙盒
            [[NSUserDefaults standardUserDefaults] setObject:currentVerson forKey:key];
            [[NSUserDefaults standardUserDefaults] synchronize];//马上同步沙盒信息
            
        }
        
    



}
@end
